//
//  LLCommitOrderGoodsCell.m
//  LoveLove
//
//  Created by 肖兰月 on 2019/4/10.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLCommitOrderGoodsCell.h"
#import "LLShoppingCartModel.h"

@interface LLCommitOrderGoodsCell ()
@property (strong, nonatomic) UIImageView *imgView;
@property (strong, nonatomic) UILabel *titleLbl;
@property (strong, nonatomic) UILabel *priceLbl;
@property (strong, nonatomic) UILabel *countLbl;
@end

@implementation LLCommitOrderGoodsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)initSubViews {
    _imgView = [UIImageView new];
    _imgView.frame = CGRectMake(10, 10, 85, 85);
    _imgView.layer.cornerRadius = 5;
    _imgView.contentMode = UIViewContentModeScaleAspectFill;
    _imgView.clipsToBounds = YES;
    _imgView.backgroundColor = LLColorRGB(210);
    [self.contentView addSubview:_imgView];

    CGFloat marigin = 10;
    _titleLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(62) font:13 textAlignment:NSTextAlignmentLeft];
    _titleLbl.frame = CGRectMake(_imgView.right+marigin, _imgView.top, LLScreenWidth-marigin*2-_imgView.right, 40);
    _titleLbl.numberOfLines = 2;
    [self.contentView addSubview:_titleLbl];

    _priceLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(66) font:13 textAlignment:NSTextAlignmentLeft];
    _priceLbl.frame = CGRectMake(_titleLbl.left, _imgView.bottom-20, _titleLbl.width-81, 20);
    [self.contentView addSubview:_priceLbl];
    
    _countLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(66) font:10 textAlignment:NSTextAlignmentRight];
    _countLbl.frame = CGRectMake(_titleLbl.right-80, _imgView.bottom-20, 80, 20);
    [self.contentView addSubview:_countLbl];
    
}

- (void)setModel:(LLShoppingCartModel *)model {
    _model = model;
    [_imgView sd_setImageWithURL:LLImageWithUrl(model.imgUrl) placeholderImage:LLGoodsPlaceholderImage options:SDWebImageRefreshCached];
    _titleLbl.text = model.title;
    _priceLbl.text = [NSString stringWithFormat:@"¥%@", model.price];
    _countLbl.text = [NSString stringWithFormat:@"X%@", model.countStr];
}


@end
